//
//  MyStockCenter.m
//  Stock
//
//  Created by sun black on 11-7-24.
//  Copyright 2011年 __MyCompanyName__. All rights reserved.
//

#import "MyStockCenter.h"

@implementation MyStockCenter



- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}
-(void)reloadViews{
    
    UIColor *green = [UIColor greenColor];
    UIColor *red = [UIColor redColor];
    
    label2.textColor = [myStock.changedPrice hasPrefix:@"-"]?green:red;
    label3.textColor = [myStock.changedRate hasPrefix:@"-"]?green:red;
    
    label1.text = [myStock.closingPrice stringValue];
    label2.text = myStock.changedPrice;
    label3.text = myStock.changedRate;
    label4.text = [myStock.lastClosingPrice stringValue];
    label5.text = [myStock.maxPrice stringValue];
    label6.text = [myStock.minPrice stringValue];
    label7.text = myStock.turnoverMoney;
    label8.text = myStock.turnover;
    
    NSLog(@"dateTime=%@,ff=%@",myStock.dateTime,myStock.ff);
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"MM-dd HH:mm"];
    NSDate *date = [[NSDate alloc] initWithTimeIntervalSince1970:[myStock.dateTime longLongValue]];
    self.label9.text = [dateFormatter stringFromDate:date];
    [date release];
    [dateFormatter release];
    
    
}
-(void)setupSelf{
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateStockSuccess:) name:kUpdateStockNotification object:nil];
}
- (void)updateStockSuccess:(NSNotification *)nodification{
    StockListController *sender = nodification.object;
    self.myStock = sender.myStock;
    [self reloadViews];
    
}
- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}
-(void)dealloc{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    [super dealloc];
}

@end
